Skip to content

fix(opentelemetry): Add conditional browser export to avoid node deps#20556

Merged
mydea merged 3 commits intodevelopfrom
fn/fix-otel-export
Apr 29, 2026
Merged

fix(opentelemetry): Add conditional browser export to avoid node deps#20556
mydea merged 3 commits intodevelopfrom
fn/fix-otel-export

Conversation

@mydea
Copy link
Copy Markdown
Member

@mydea mydea commented Apr 28, 2026

We accidentally added a node dependency to an export from opentelemetry package, leading to problems for users using this in a browser environment.

This PR adds conditional exports to the opentelemetry package, where for browser targets we have stubs for the node-only thing. This should generally work the same as before, but stop failing builds in browser envs.

I had to adjust browser integration tests for this a bit, as they did some unnecessary aliasing which prevented webpack from using normal conditional exports. We are simply doing less now and doing regular dependency resolution which should work as expected (hopefully).

@mydea mydea self-assigned this Apr 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 26.16 kB - -
@sentry/browser - with treeshaking flags 24.63 kB - -
@sentry/browser (incl. Tracing) 44.11 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 46.11 kB - -
@sentry/browser (incl. Tracing, Profiling) 49.06 kB - -
@sentry/browser (incl. Tracing, Replay) 83.36 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 72.84 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 88.03 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 100.69 kB - -
@sentry/browser (incl. Feedback) 43.4 kB - -
@sentry/browser (incl. sendFeedback) 30.96 kB - -
@sentry/browser (incl. FeedbackAsync) 36.14 kB - -
@sentry/browser (incl. Metrics) 27.44 kB - -
@sentry/browser (incl. Logs) 27.59 kB - -
@sentry/browser (incl. Metrics & Logs) 28.28 kB - -
@sentry/react 27.9 kB - -
@sentry/react (incl. Tracing) 46.35 kB - -
@sentry/vue 31.03 kB - -
@sentry/vue (incl. Tracing) 45.95 kB - -
@sentry/svelte 26.18 kB - -
CDN Bundle 28.84 kB - -
CDN Bundle (incl. Tracing) 46.65 kB - -
CDN Bundle (incl. Logs, Metrics) 30.25 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 47.73 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 69.25 kB - -
CDN Bundle (incl. Tracing, Replay) 83.75 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 84.82 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 89.57 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 90.65 kB - -
CDN Bundle - uncompressed 84.55 kB - -
CDN Bundle (incl. Tracing) - uncompressed 139.56 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 88.75 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 143.02 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 212.39 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 257.07 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 260.51 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 270.77 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 274.2 kB - -
@sentry/nextjs (client) 48.84 kB - -
@sentry/sveltekit (client) 44.56 kB - -
@sentry/node-core 58.81 kB -0.05% -25 B 🔽
@sentry/node 169.14 kB -0.49% -823 B 🔽
@sentry/node - without tracing 96.66 kB -1.01% -980 B 🔽
@sentry/aws-serverless 113.53 kB -0.72% -822 B 🔽
@sentry/cloudflare (withSentry) - minified 163.65 kB - -
@sentry/cloudflare (withSentry) 414.17 kB - -

View base workflow run

@mydea mydea force-pushed the fn/fix-otel-export branch from 4e32f21 to 3924a95 Compare April 28, 2026 09:48
@mydea mydea requested a review from a team April 28, 2026 09:50
@mydea mydea marked this pull request as ready for review April 28, 2026 12:01
@isaacs isaacs self-requested a review April 28, 2026 15:01
Copy link
Copy Markdown
Member

@isaacs isaacs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Minor possible safety improvement suggestion, but mostly theoretical.

"types": "./build/types/index.d.ts",
"default": "./build/esm/index.js"
},
"browser": {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're specifying browser here, it might be safer to put it above node, just to ensure that anything that claims to support this (even if it does so with weird shims etc) can pick up the browser one first.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't 100% sure about this (and still am not 🤔 ) my thinking for this was that node is def. the main target here, and I want to avoid somebody who has a node target not getting this. IMHO that's more important than somebody who has node & browser targets not getting the node stuff - I'd say it's reasonable that if your targets include node, you get the variant with the node import 😅 but we can always revisit the order if this turns out to be problematic!

@mydea mydea merged commit a4e888f into develop Apr 29, 2026
207 of 210 checks passed
@mydea mydea deleted the fn/fix-otel-export branch April 29, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants